package com.example.common.entity;

import jakarta.persistence.*;
import lombok.Data;

import java.math.BigInteger;


@Entity
@Table(name = "sys_roles_depts")
@Data
public class SysRolesDepts {

    @EmbeddedId
    private SysRolesDeptsId id;

    @ManyToOne
    @MapsId("roleId")
    @JoinColumn(name = "role_id", referencedColumnName = "role_id")
    private SysRole sysRole;
    
    @ManyToOne
    @MapsId("deptId")
    @JoinColumn(name = "dept_id", referencedColumnName = "dept_id")
    private SysDept sysDept;
    
    @Transient
    public BigInteger getRoleId() {
        return sysRole.getRoleId();
    }
    
    public void setRoleId(BigInteger roleId) {
        SysRole role = new SysRole();
        role.setRoleId(roleId);
        this.sysRole = role;
    }
    
    @Transient
    public BigInteger getDeptId() {
        return sysDept.getDeptId();
    }
    
    public void setDeptId(BigInteger deptId) {
        SysDept dept = new SysDept();
        dept.setDeptId(deptId);
        this.sysDept = dept;
    }
}
